home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 May / SGI IRIX 6.5 Complementary Applications 2004 May.iso / dist / OpenOffice.idb / usr / OpenOffice / help / en / sbasic.jar / text / sbasic / common / 03050500.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-24  |  3.1 KB  |  54 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>On Error GoTo...Resume Statement [Runtime]</title><meta name="filename" content="text/sbasic/common/03050500"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         p.P1{
  5.                 }
  6.         p.P2{
  7.                 }
  8.         span.T1{
  9.                 font-weight:bold;}
  10.         </style></head><body>
  11.   
  12.   
  13.   <help:to-be-embedded Eid="onerrorgotoresume" xmlns:help="http://openoffice.org/2000/help">
  14.   <p class="Head1"><help:key-word value="On Error GoTo...Resume" tag="kw66498_1"/><help:link Id="66498">On Error GoTo...Resume Statement [Runtime]</help:link></p>
  15.   <p class="Paragraph">Enables an error-handling routine after an error occurs, or resumes program execution.</p>
  16.   </help:to-be-embedded>
  17.   <p class="Paragraph"><span class="T1">Syntax</span>:</p>
  18.   <p class="Paragraph">On [Local] {Error GoTo Labelname | GoTo 0 | Resume Next}</p>
  19.   <p class="Paragraph"><span class="T1">Parameter</span>:</p>
  20.   <p class="Paragraph">Local: Defines a local error-handling routine for a procedure. If this parameter is omitted, the error-handling is valid for the entire module.</p>
  21.   <p class="Paragraph">GoTo Labelname: If an error occurs, enables the error-handling routine that starts at the line "Labelname".</p>
  22.   <p class="Paragraph">Resume Next: If an error occurs, program execution continues with the statement following the statement in which the error occurred.</p>
  23.   <p class="Paragraph">GoTo 0: Disables the error handler in the current procedure.</p>
  24.   <p class="Paragraph">The On Error GoTo statement is used to react to errors that may occur in a macro. The statement must be inserted at the start of a procedure (in a local error-handling routine) or at the start of the module.</p>
  25.   <p class="P2">Example:</p>
  26.   <p class="PropText">Sub ExampleReset</p>
  27.   <p class="PropText">On Error Goto ErrorHandler</p>
  28.   <p class="PropText">Dim iNumber As Integer</p>
  29.   <p class="PropText">Dim iCount As Integer</p>
  30.   <p class="PropText">Dim sLine As String</p>
  31.   <p class="PropText">Dim aFile As String</p>
  32.   <p class="PropText">aFile = "c:\data.txt"</p>
  33.   <p class="PropText"/>
  34.   <p class="PropText">iNumber = Freefile</p>
  35.   <p class="PropText">Open aFile For Output As #iNumber</p>
  36.   <p class="PropText">Print #iNumber, "This is a line of text"</p>
  37.   <p class="PropText">Close #iNumber</p>
  38.   <p class="PropText"/>
  39.   <p class="PropText">iNumber = Freefile</p>
  40.   <p class="PropText">Open aFile For Input As iNumber</p>
  41.   <p class="PropText">For iCount = 1 to 5</p>
  42.   <p class="PropText">Line Input #iNumber, sLine</p>
  43.   <p class="PropText">If sLine <>"" then</p>
  44.   <p class="PropText">rem</p>
  45.   <p class="PropText">end if</p>
  46.   <p class="PropText">Next iCount</p>
  47.   <p class="PropText">Close #iNumber</p>
  48.   <p class="PropText">Exit Sub</p>
  49.   <p class="PropText">ErrorHandler:</p>
  50.   <p class="PropText">Reset</p>
  51.   <p class="PropText">MsgBox "All files will be closed",0,"Error"</p>
  52.   <p class="PropText">End Sub</p>
  53.   <p class="PropText"/>
  54.  </body></html>